package lambda;

import arrays.People;

import java.util.ArrayList;

public class LambaTest1 {
    public static void main(String[] args) {
        // Lamba 表达式只能简化函数接口类型的匿名内部类
        Swimming s = () -> System.out.println("快速游泳");
        s.swim();
        Swimming zjd = new Swimming() {
            @Override
            public void swim() {
                System.out.println("zjd");
                System.out.println("zjd");
            }
        };


        Swimming zjd2 = () -> {
            System.out.println("zjd");
            System.out.println("zjd");
        };



        ArrayList<People> people = new ArrayList<>();
        People people2 = new People();
        people2.setName("wyb");
        People people3 = new People();
        people3.setName("zzb");
        People people4 = new People();
        people.add(people3);
        people.add(people4);
        people.add(people2);
        for (People person : people) {
            System.out.println(person.getName());
        }
        people.forEach(people1 -> System.out.println(people1.getName()));
        for (int i = 0; i < people.size(); i++) {
            System.out.println(people.get(i).getName());
        }
    }


}

interface Swimming{
    void swim();
}